#include "stdafx.h"
#include "ErrorHelper.h"
#include "..\WMP\Common.h"

#pragma unmanaged

BOOL WINAPI CheckError(HWND hWnd) {
	CreateTextBuffer(textBuffer);

	HWND item = GetDlgItem(hWnd, 0xC9);
	if (item == NULL)
		return false;
	//int len = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0);
	if (!SendMessage(hWnd, WM_GETTEXT, textBufferLength, (LPARAM)textBuffer) || !*textBuffer)
		return false;
	HMODULE herr = GetModuleHandle(_T("wmerror.dll"));
	if (herr == NULL)
		return false;
	LPTSTR buf;
	if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
		herr, 0x0C00D0FD6, 0x400, (LPTSTR)&buf, 0, NULL))
		return false;
	BOOL res;
	try {
		res = lstrcmpi(textBuffer, buf) == 0;
	} finally (
		LocalFree(buf);
	)
	return res;
}


